import {createWebHashHistory} from "vue-router";
import _ from 'lodash'
import * as AppRouter from "../../../ark/router/app-router.ts";
import appRoutes from "../index.js";

export default AppRouter.createRouter(
    {
      history: createWebHashHistory(),
      routes: appRoutes,
    },
    {
      showLoading: true,
      afterShowLoading(to) {
        // const title = to.meta?.title;
        // if (title) {
        //     document.title = `${title} - XX系统`;
        // }
      },

      excludeList(to, from) {
        // 此处常用于在默认route模式(BLOCK)下添加无需token验证的路由白名单
        const allowlist: string[] = [];
        _.forOwn(appRoutes, (value, key) => {
          if (value.meta?.allow) {
            allowlist.push(value.path);
          }
        });
        return allowlist
      },
      nonInExcludeListRoutePermit(to) {
        // 此处常用于在默认route模式(BLOCK)下添加判断是否token验证
        // return useGeneralStore().isLogin;
        return true
      },
    }
);